/*
 * Thread.cpp
 *
 *  Created on: Jan 8, 2015
 *      Author: toti
 */

#include <Threads/Thread.hpp>


Thread::Thread(Runnable *runnable){

	this->runnable = runnable;
	thread = 0;

}


void *Thread::startThread(void *thread){
	((Thread*)thread)->runnable->run();
	return 0;
}

void Thread::start(){

	/* Start new thread */
	pthread_create(&thread, 0, Thread::startThread, (void*)this);

}

void Thread::join(){

	pthread_join(thread, 0);

}
